#ifndef _FILE_H_
#define _FILE_H_

#include <windows.h>
#include "types.h"

class file
{
public:
	 file();
	 file(const char* _name,bool _write=false);
	~file();

	u32  open(const char* _name,bool _write=false);
	u32  read(void* _buf,u32 _size);
	u32  write(void* _buf,u32 _size);
	u32  size();
	void seek(u32 _offset);
	void close();

	file& operator<<(int _val);
	file& operator<<(float _val);
	file& operator<<(const char* _val);

	file& operator>>(int& _val);
	file& operator>>(float& _val);
	file& operator>>(char* _val);

private:
	HANDLE		m_file;
	bool		m_opened;
	bool		m_writable;
	u32			m_size;
	u32			m_cursor;
};

#endif